home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / OS Utilities / jGNE Helper / native jGNE / native jGNE.c < prev   
Encoding:
C/C++ Source or Header  |  1996-01-09  |  1.6 KB  |  80 lines  |  [TEXT/CWIE]

  1. #define OLDROUTINELOCATIONS        0
  2. #define OLDROUTINENAMES            0
  3. #define SystemSevenOrLater        1
  4.  
  5. #ifndef __FONTS__
  6. #    include <Fonts.h>
  7. #endif
  8.  
  9. #ifndef __DIALOGS__
  10. #    include <Dialogs.h>
  11. #endif
  12.  
  13. #ifndef __LOWMEM__
  14. #    include <LowMem.h>
  15. #endif
  16.  
  17. static pascal OSErr InitMac (void)
  18. {
  19.     MaxApplZone ( );
  20.     InitGraf (&(qd.thePort));
  21.     InitFonts ( );
  22.     InitWindows ( );
  23.     InitMenus ( );
  24.     TEInit ( );
  25.     InitDialogs (nil);
  26.  
  27.     return noErr;
  28. }
  29.  
  30. static GetNextEventFilterUPP gGetNextEventFilterUPP;
  31. static Boolean gFilterDone;
  32.  
  33. static void myGetNextEventFilter (EventRecord *event, Boolean *result)
  34. {
  35.     //
  36.     //    IMPORTANT NOTE: It's not possible to declare a 68K jGNEFilter
  37.     //    this way! Examine one of the jGNE Helper projects for an example
  38.     //    of a 68K jGNEFilter. I hope to produce a "fat" filter some time
  39.     //    in the near future.
  40.     //
  41.  
  42.     if (gGetNextEventFilterUPP)
  43.         CallGetNextEventFilterProc (gGetNextEventFilterUPP,event,result);
  44.  
  45.     if (*result && event->what == mouseDown)
  46.     {
  47.         event->what = nullEvent;
  48.         *result = false;
  49.         gFilterDone = true;
  50.     }
  51. }
  52.  
  53. void main (void)
  54. {
  55.     if (!InitMac ( ))
  56.     {
  57.         GetNextEventFilterUPP myFilterUPP = NewGetNextEventFilterProc (myGetNextEventFilter);
  58.  
  59.         if (myFilterUPP)
  60.         {
  61.             gGetNextEventFilterUPP = LMGetGNEFilter ( );
  62.             LMSetGNEFilter (myFilterUPP);
  63.  
  64.             do
  65.             {
  66.                 EventRecord event;
  67.                 WaitNextEvent (everyEvent,&event,1,nil);
  68.             }
  69.             while (!gFilterDone);
  70.  
  71.             if (LMGetGNEFilter ( ) != myFilterUPP)
  72.                 DebugStr ("\pSomeone else has gotten into the jGNE filter chain!");
  73.             else
  74.                 LMSetGNEFilter (gGetNextEventFilterUPP);
  75.  
  76.             DisposeRoutineDescriptor (myFilterUPP);
  77.         }
  78.     }
  79. }
  80.